<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('远程踏勘列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <input type="hidden" id="yctk" name="yctk" th:value="${yctk}">
                <input type="hidden" id="user" name="user" th:value="${user}">
                <input  type="hidden" id="state" name="state" >
                <div class="select-list">
                    <ul>
                        <li>
                            <p>经营者：</p>
                            <input type="text" name="username"/>
                        </li>

                        <li>
                            <p>商户名称：</p>
                            <input type="text" name="qyName"/>
                        </li>
                        <li>
                            <p>身份证号：</p>
                            <input type="text" name="sfzcard"/>
                        </li>
                        <li>
                            <p>手机号：</p>
                            <input type="text" name="phone"/>
                        </li>


                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div th:if="${yctk}==0" class="btn-group-sm" id="toolbar" role="group">
<!--            shiro:hasPermission="system:projectzj:add"-->
            <a  class="btn btn-success" onclick="$.operate.addTab()" > <i
                    class="fa fa-plus"></i> 新增踏勘 </a>
<!--            shiro:hasPermission="wsyy:wsyy:remove"-->
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()"
             >
                <i class="fa fa-remove"></i> 删除
            </a>
<!--            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="wsyy:wsyy:export">-->
<!--                <i class="fa fa-download"></i> 导出-->
<!--            </a>-->
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table" data-mobile-responsive="true"></table>
        </div>
    </div>
</div>


<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var yctk=$("#yctk").val();
    var removeFlag = [[${@permission.hasPermi('wsyy:wsyy:remove')}]];
    var prefix = ctx + "Rong";
    var site = [[${@dict.getType('wsyy_site')}]];
    $(function () {
        var options = {
            url: prefix + "/list/"+yctk,
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            viewUrl: prefix + "/export/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "",
            resetUrl: prefix + "/reset",
            sortName: "addTime",
            sortOrder: "desc",
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: '主键',
                    visible: false
                },
                {
                    field: 'username',
                    title: '经营者（业主）名称',

                },
                {
                    field: 'sfzcard',
                    title: '身份证号',
                    formatter: function (value, row, index) {
                        return strTools(value);
                    }

                },
                {
                    field: 'qyName',
                    title: '经营者名称',
                    formatter: function (value, row, index) {
                        return strTools(value,row);
                    }
                },
                {
                    field: 'tk_realname',
                    title: '踏勘人员',

                },

                {
                    field: 'makedate',
                    title: '踏勘时间',

                },
                {
                    field: 'add_Time',
                    title: '添加时间',
                },
                {
                    field: 'isfinish',
                    title: '状态',
                    formatter: function (value, row, index) {
                        return strIsfinish(value,row);
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        if([[${yctk}]]==0 || [[${yctk}]]==1){
                            actions.push('<a class="btn btn-info btn-xs  " href="#"  onclick="view(\'' + row.id + '\')"><i class="fa fa-info-circle"></i> 踏勘</a>');
                            actions.push('<a class="btn btn-info btn-xs '  + '" href="#"  onclick="$.operate. editTab(\'' + row.id+ '\')"><i class="fa fa-edit"></i>修改</a>');
                        }
                        if([[${yctk}]]==2){
                            actions.push('<a class="btn btn-info btn-xs '  + '" href="#"  onclick="$.operate. editTab(\'' + row.id+ '\')"><i class="fa fa-edit"></i>查看</a>');
                        }

                        return actions.join('');
                    }
                }]
        };

        $.table.init(options);
    });
    function view(id) {
        $.modal.openTab("远程踏勘" + $.table._option.modalName,  prefix + "/export/"+id);
    }
    function strTools(value) {
        if(value!=null){
            if (value.length > 10) {
                return value.substr(0, 10) + "...";
            }
        }
        return value;
    }
    function strIsfinish(value,row) {
        switch(value){
            case '0' :
                return '未踏勘'
                break;
            case '1' :
                return '通过'
                break;
            case '2' :
                return '未通过'
                break;
            case '3' :
                return '<a   onclick="$.operate.chongzhi(\'' + row.id + '\')">踏勘中(重置状态)</a>'
                break;
            case '4' :
                return '整改中'
                break;
        }
    }
    function chongzhi(id) {
        alert("重置:"+id)
    }

</script>
</body>
</html>
